package com.ruoyi.eqmonitor.service.impl;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.eqmonitor.domain.OptSewagePump;
import com.ruoyi.eqmonitor.mapper.OptSewagePumpMapper;
import com.ruoyi.eqmonitor.service.IOptDeviceService;
import com.ruoyi.eqmonitor.service.IOptSewagePumpService;
import com.ruoyi.eqmonitor.utils.Constant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 污水厂与泵站明细Service业务层处理
 *
 * @author ruoyi
 * @date 2022-12-16
 */
@Service
public class OptSewagePumpServiceImpl extends ServiceImpl<OptSewagePumpMapper, OptSewagePump> implements IOptSewagePumpService {

    @Resource
    private IOptDeviceService iOptDeviceService;

    @Override
    public OptSewagePump selectOptSewagePumpById(Long id){
        return baseMapper.selectOptSewagePumpById(id);
    }

    @Override
    public List<OptSewagePump> selectOptSewagePumpList(OptSewagePump optSewagePump){
        return baseMapper.selectOptSewagePumpList(optSewagePump);
    }

    @Override
    public List<OptSewagePump> getAll() {
        return baseMapper.getAll();
    }

    @Override
    public Map<String, Object> getSewagePumpAndDevice() {
        Map<String, Object> result = new HashMap<>();
        result.put("pumpList", baseMapper.getAll());
        List<String> deviceTypes = Arrays.stream(Constant.EquipmentType.values()).filter(equipmentType -> {
            // 不查井盖
            return !Constant.EquipmentType.SJ300_N_D2.equals(equipmentType);
        }).map(Constant.EquipmentType::getCode).distinct().collect(Collectors.toList());
        result.put("deviceList", iOptDeviceService.selectPumpStationDeviceList(deviceTypes));
        return result;
    }
}
